//FileTableFormat.java
import java.util.*;
import ca.odell.glazedlists.GlazedLists;
import ca.odell.glazedlists.gui.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FileTableFormat implements AdvancedTableFormat {

   public int getColumnCount() {
       return IColumnKeys.s_NUMCOLUMNS;
   }

   public String getColumnName(int column) {
       if(column == IColumnKeys.s_NAME) return "Name";
       else if(column == IColumnKeys.s_SIZE) return "Size (KB)";
       else if(column == IColumnKeys.s_LASTMOD) return "Last Modified";
       else if(column == IColumnKeys.s_KEYWORDS) return "Key Words";
       else if(column == IColumnKeys.s_EXTENSION) return "Extension";
       else if(column == IColumnKeys.s_ARTIST) return "Artist";
       else if(column == IColumnKeys.s_GENRE) return "Genre";
       else if(column == IColumnKeys.s_DIMENSION) return "Dimension";
       else if(column == IColumnKeys.s_DIRECTOR) return "Director";
       else if(column == IColumnKeys.s_PREVIEW) return "Preview";
       else if(column == IColumnKeys.s_ALBUM) return "Album";
       else if(column == IColumnKeys.s_TIME) return "Time";


       throw new IllegalStateException();
   }

   public Object getColumnValue(Object baseObject, int column) {
       DBFile fi = (DBFile)baseObject;

       if(column == IColumnKeys.s_NAME) return fi.getPath();
       else if(column == IColumnKeys.s_SIZE) return fi.length()/1000;
       else if(column == IColumnKeys.s_LASTMOD) return fi.lastModified();
       else if(column == IColumnKeys.s_KEYWORDS) return fi.getKeyWords();
       else if(column == IColumnKeys.s_EXTENSION) return fi.getExt();
       else if(column == IColumnKeys.s_ARTIST) return fi.getArtist();
       else if(column == IColumnKeys.s_GENRE) return fi.getGenre();
       else if(column == IColumnKeys.s_DIMENSION) return fi.getDimension();
       else if(column == IColumnKeys.s_DIRECTOR) return fi.getDirector();
       else if(column == IColumnKeys.s_PREVIEW) return fi.getPath();
       else if(column == IColumnKeys.s_ALBUM) return fi.getAlbum();
       else if(column == IColumnKeys.s_TIME) return fi.getMusicLength();

       throw new IllegalStateException();
   }

   public Class getColumnClass(int column) {
      return Object.class;
   }

   public Comparator getColumnComparator(int column) {
      if(column == 0) return GlazedLists.caseInsensitiveComparator();
      else return GlazedLists.comparableComparator();
   }

}
